package com.qulai.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.qulai.amazon_us.domain.basic.Image;
import com.qulai.amazon_us.domain.vo.ImageApprovalVo;
import com.qulai.amazon_us.service.basic.IImageService;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qulai.common.annotation.Log;
import com.qulai.common.core.controller.BaseController;
import com.qulai.common.core.domain.AjaxResult;
import com.qulai.common.enums.BusinessType;
import com.qulai.amazon_us.domain.basic.ImageApproval;
import com.qulai.amazon_us.service.basic.IImageApprovalService;
import com.qulai.common.utils.poi.ExcelUtil;
import com.qulai.common.core.page.TableDataInfo;

/**
 * 图片审核Controller
 * 
 * @author hunan
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/basic/ImageApproval")
public class ImageApprovalController extends BaseController
{
    @Autowired
    private IImageApprovalService imageApprovalService;


    /**
     * 查询图片审核列表
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImageApproval imageApproval)
    {
        startPage();
        List<ImageApprovalVo> list = imageApprovalService.selectImageApprovalVoList(imageApproval);
        return getDataTable(list);
    }
    @GetMapping("/getListBySku/{sku}")
    public List<ImageApproval> getListBySku(@PathVariable("sku") String sku)
    {
        return imageApprovalService.selectImageApprovalListBySku(sku);
    }

    /**
     * 导出图片审核列表
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:export')")
    @Log(title = "图片审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImageApproval imageApproval)
    {
        List<ImageApproval> list = imageApprovalService.selectImageApprovalList(imageApproval);
        ExcelUtil<ImageApproval> util = new ExcelUtil<ImageApproval>(ImageApproval.class);
        util.exportExcel(response, list, "图片审核数据");
    }



    /**
     * 获取图片审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(imageApprovalService.selectImageApprovalById(id));
    }

    /**
     * 新增图片审核
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:add')")
    @Log(title = "图片审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImageApproval imageApproval)
    {
        return toAjax(imageApprovalService.insertImageApproval(imageApproval));
    }

    /**
     * 修改图片审核
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:edit')")
    @Log(title = "图片审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImageApproval imageApproval)
    {
        return toAjax(imageApprovalService.updateImageApproval(imageApproval));
    }


    @PostMapping ("/approval")
    public AjaxResult approval(@RequestBody List<ImageApproval> list)
    {
        return toAjax(imageApprovalService.approval(list));
    }

    /**
     * 删除图片审核
     */
    @PreAuthorize("@ss.hasPermi('basic:ImageApproval:remove')")
    @Log(title = "图片审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imageApprovalService.deleteImageApprovalByIds(ids));
    }

}
